﻿using UnityEngine;

namespace Pumpkin.FrameBase
{
    public static class ResHelper
    {
        public static IResLoader Loader { get => resLoader; }

        private static IResLoader resLoader;
        public static void SetResloader(IResLoader loader)
        {
            resLoader = loader;
        }

        public static T LoadAsset<T>(string path, bool autoUnload = false) where T : UnityEngine.Object
        {
            return resLoader.LoadAsset<T>(path, autoUnload);
        }

        public static UnityEngine.Object LoadAsset(string path, bool autoUnload = false)
        {
            return resLoader.LoadAsset<UnityEngine.Object>(path, autoUnload);
        }

        public static TextAsset LoadText(string path, bool autoUnload = false)
        {
            return resLoader.LoadAsset<TextAsset>(path, autoUnload);
        }

        public static GameObject LoadPrefab(string path, bool autoUnload = false)
        {
            return resLoader.LoadAsset<GameObject>(path, autoUnload);
        }

        public static Texture LoadTexture(string path, bool autoUnload = false)
        {
            return resLoader.LoadAsset<Texture>(path, autoUnload);
        }

        public static void PreLoadCommonRes()
        {
            resLoader.PreLoadCommonRes();
        }

        public static void PreLoadSceneRes(string sceneName)
        {
            resLoader.PreLoadSceneRes(sceneName);
        }

        public static void UnLoadBundle(string bundleName)
        {
            resLoader.UnLoadBundle(bundleName);
        }
    }
}
